<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="list">
      <div
        data-preload-main=""
        data-preload-url="https://d16tvu8s9o80e8.cloudfront.net/Harbour_Space_18a9330d05.jpg"
      ></div>
      <div
        data-preload-main=""
        data-preload-url="https://d16tvu8s9o80e8.cloudfront.net/Student_App_c966538eaf.jpg"
      ></div>
      <div
        data-preload-main=""
        data-preload-url="https://d16tvu8s9o80e8.cloudfront.net/Barkyn_95fb47f9c4.jpg"
      ></div>
      <div
        data-preload-main=""
        data-preload-url="https://d16tvu8s9o80e8.cloudfront.net/Humana_b6f0c4b99c.jpg"
      ></div>
    </div>

    <div
      class="loading"
      style="
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #fff;
        z-index: 10;
      "
    >
      loading...
    </div>
    <div class="pic-wrapper">
      <img
        class="pic"
        src="https://d16tvu8s9o80e8.cloudfront.net/Student_App_c966538eaf.jpg"
        alt=""
      />
    </div>

    <script type="module">
      import gsap from "../_snowpack/pkg/gsap.js";
      import preloader from "../dist/app/utils/preloader/index.js";

      const preload1 = new preloader({ xhrImages: false, throttle: 0 });
      const preloadElements = gsap.utils.toArray(
        document.querySelectorAll("[data-preload-main]")
      );
      preloadElements.forEach((el2) => {
        preload1.add(el2.dataset.preloadUrl);
      });

      // 图片每加载一张执行就执行函数
      preload1.on("progress", (progress) => {
        console.log(`progress: ${progress}`);
      });

      preload1.on("complete", () => {
        document.querySelector(".loading").style.display = "none";
        console.log("all content loaded!");
      });
      // 开始加载过程
      preload1.load();

      var imageData = {
        endAngle: 0,
        middleAngle: 0,
        startAngle: 0,
        travelXStart: 0,
        travelXMiddle: 0,
        travelXEnd: 0,
        rotation: 0,
        rotationCenter: 0,
      };
      var values = {
        endAngle: -8,
        middleAngle: 9.5,
        startAngle: 28,
        travelXStart: 0,
        travelXMiddle: 4,
        travelXEnd: 8,
        containerRotation: 2,
        rotationCenter: 1.5,
      };
      var tl = gsap.timeline();
      tl.from(".pic-wrapper", {
        yPercent: 200,
        duration: 2,
      }, 0);
      tl.to(imageData, {
        startAngle: values.startAngle * 0.5,
        middleAngle: values.middleAngle * 0.5,
        endAngle: values.endAngle * 0.5,
        duration: 2.169,
        ease: "none"
      }, 0);
    </script>
  </body>
</html>
